using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using NBusiness.CodeDom;
using NBusiness.Query;

namespace NBusiness.Data
{
    public interface IDatabaseProvider
    {
        DbConnection GetConnection(string connectionString);

        void Insert(DbTransaction transaction, string command, LoadIdentityHandler loadIdentity, params Parameter[] parameters);

        void Update(DbTransaction transaction, string command, params Parameter[] parameters);

        void Delete(DbTransaction transaction, string command, params Parameter[] parameters);

        void Fetch(DbConnection connection, string command, CriteriaBase criteria, EventHandler<LoadEventArgs> load, params Parameter[] parameters);

        int FetchCollection(DbConnection connection, string command, CriteriaBase criteria, EventHandler<LoadEventArgs> load, int startIndex, int maxRows, string sortField, SortOrder sortOrder, params Parameter[] parameters);

        void Query(DbConnection connection, QueryCriteria query, EventHandler<LoadEventArgs> load);
    }
}
